﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DatabaseCompare.Model
{

    /// <summary>
    /// 视图 比较结果
    /// </summary>
    public class ViewCompareResult : CompareAbleResult<ViewInfo>
    {

        /// <summary>
        /// 创建视图的 SQL 信息不同.
        /// </summary>
        public bool CreateViewSQLDifference { set; get; }


        /// <summary>
        /// 列的比较信息列表.
        /// </summary>
        public List<ColumnCompareResult> ColumnCompareResultList { set; get; }



        public override string GetDifferenceString()
        {
            StringBuilder buff = new StringBuilder();
            buff.Append("不匹配[");
            if (CommentDifference)
            {
                buff.AppendFormat("备注/说明信息({0},{1})", Left.Comment, Right.Comment);
            }

            if (CreateViewSQLDifference)
            {
                buff.AppendFormat("创建视图脚本({0},{1})", Left.CreateViewSQL, Right.CreateViewSQL);
            }

            for (int i = 0; i < ColumnCompareResultList.Count; i++)
            {
                if (ColumnCompareResultList[i].CompareResult != CommonCompareResult.FullSame)
                {
                    buff.AppendFormat("列[{0}]不匹配", i + 1);
                }
            }

            buff.Append("]");
            return buff.ToString();
        }
    }

}
